using System;
using System.Collections;
using System.IO;

namespace SSDS
{
    /// <summary>
    /// Summary description for FileHistory.
    /// </summary>
    public class FileHistory : TextFile
    {
        public const string FILE_HISTORY_PATH = "files.txt";
        public const int    MAX_HISTORY       = 20;

        public void Add(string Filename)
        {
            for (int i = 0; i < MAX_HISTORY; i++)
            {
                if (((string)Lines[i]).ToUpper() == Filename.ToUpper())
                {
                    return;
                }
            }

            for (int i = MAX_HISTORY-1; i > 0; i--)
            {
                Lines[i] = Lines[i-1];
            }
            Lines[0] = Filename;
        }

        public FileHistory(System.Windows.Forms.IWin32Window parent) : base (parent, FILE_HISTORY_PATH)
        {
            ReadFile();

            if (Lines.Count > 0)
            {
                return;
            }

            // Initialize the array with some preloaded paths
            Lines.Add("NOTES.TXT");
            Lines.Add("HOWTO.TXT");
            Lines.Add("democ.txt");
            Lines.Add("CRIPT.TXT");
            Lines.Add("C:\\Program Files\\Sympatico\\Users\\User1\\Mail\\Sent");
            Lines.Add("C:\\Program Files\\Sympatico\\Users\\User1\\Mail\\Inbox");
            Lines.Add("C:\\windows\\application data\\microsoft\\outlook express\\mail\\Inbox.mbx");
            Lines.Add("C:\\windows\\application data\\microsoft\\outlook express\\mail\\Sent Items.mbx");
            Lines.Add("CONTROL.TXT");

            while (Lines.Count < MAX_HISTORY)
            {
                Lines.Add("");
            }
        }
    }
}
